package com.cloudz.iptv;

import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;

import com.cloudz.iptv.fragment.BaseFragment;
import com.cloudz.iptv.fragment.footer.FooterFragment;
import com.cloudz.iptv.fragment.header.HeaderFragment;
import com.owen.focus.FocusBorder;

public class MainActivityBak extends AppCompatActivity implements BaseFragment.FocusBorderHelper
{
    FocusBorder focusBorder;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        Resources resources = this.getResources();
        Drawable btnDrawable = resources.getDrawable(R.drawable.bg5);
        this.getWindow().setBackgroundDrawable(btnDrawable);

        //隐藏bar
        if (getSupportActionBar() != null)
        {
            getSupportActionBar().hide();
        }

        setContentView(R.layout.activity_main);

        FragmentManager manager = getSupportFragmentManager();

        FragmentTransaction transaction = manager.beginTransaction();
        HeaderFragment headerFragment = new HeaderFragment();
        Fragment footerFragment = Fragment.instantiate(this, FooterFragment.class.getName());

        transaction.add(R.id.header, headerFragment);
        transaction.add(R.id.footer, footerFragment);
        transaction.commit();


        initFocusBorderAsDrawable();
    }

    /**
     * 图片焦点框
     */
    public void initFocusBorderAsDrawable()
    {
        /** 图片焦点框 */
        focusBorder = new FocusBorder.Builder().asDrawable()
                .borderDrawableRes(R.mipmap.focus)
                .titleBackgroundRes(R.drawable.shape_item_title_bg)
                .titleMarginBottomAutoAlignBorder()
                .titleTextColor(Color.LTGRAY)
                .build(this);


    }

    @Override
    public FocusBorder getFocusBorder()
    {
        return focusBorder;
    }
}
